import { defineStore } from 'pinia';
import * as Type from './type';

const usePicContent = defineStore('PicContent', {
  persist: false,
  state: (): Type.PicState => ({
    markData: {
      version: '4.6.0',
      objects: []
    }
  }),
  actions: {
    setState(partial: Type.PicState) {
      this.$patch(partial);
    },
    setData(data: Type.DataItem) {
      this.setState({
        markData: data
      });
    },
    setArr(data: any) {
      this.markData.objects.push(data);
    },
    clearState() {
      this.markData = {
        version: '4.6.0',
        objects: []
      };
    }
  }
});

export default usePicContent;